<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="button" tag="login">点击打开登录浮层</button>
<script>
Function.prototype.after = function(afterfn) {
  let __self = this;
  return function() {
    let ret = __self.apply(this, arguments);
    afterfn.apply(this, arguments);
    return ret;
  }
};
let showLogin = function() {
  console.log('打开登录浮层');
}
let log = function() {
  console.log('上报标签为：' + this.getAttribute('tag'));
}
showLogin = showLogin.after(log)
document.getElementById('button').onclick = showLogin

Function.prototype.before = function(beforefn) {
  let __self = this;
  return function() {
    beforefn.apply(this, arguments);
    return __self.apply(this, arguments);
  }
};
let func = function(param) {
  console.log(param);
}
func = func.before(function(param) {
  param.b = 'b'
})
func({ a: 'a' })

let ajax = function(type, url, param) {
  console.log(param);
}
let getToken = function() {
  return 'Token'
}
ajax = ajax.before(function(type, url, param) {
  param.Token = getToken()
})
ajax('get', 'http://xxx', { name: 'july' })

</script>
</body>
</html>